﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 软件界面2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            //展开组件中的所有节点
            treeView1.ExpandAll();
            this.panel1.Visible = false;

            if (e.Node.Name == "11")
            {
                //tabControl1.Visible = true;
                this.tabControl1.SelectedTab=tabPage1;
            }
            else 
            if (e.Node.Name == "12")
            {
                //tabControl1.Visible = true;
                this.tabControl1.SelectedTab = tabPage14;
            }
            else 
            if (e.Node.Name == "13")
            {
                //tabControl1.Visible = true;
                this.tabControl1.SelectedTab = tabPage15;
            }
            else 
            if (e.Node.Name == "14")
            {
                //tabControl1.Visible = true;
                this.tabControl1.SelectedTab = tabPage16;
            }
            else 
            if (e.Node.Name == "21")
            {
                //tabControl1.Visible = true;
                this.tabControl1.SelectedTab = tabPage6;
                openFileDialog1.Filter = "数据文件(*.dat)|*.dat|所有文件|*.*";
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    string str = openFileDialog1.FileName;
                    System.Diagnostics.Process.Start(str);
                }
                //Form3 frm3= new Form3();
                //frm3.Show();
            }
            else
            if (e.Node.Name == "22")
            {
                //tabControl1.Visible = true;
                this.tabControl1.SelectedTab = tabPage7;
                saveFileDialog1.Filter = "文本文件|*.txt|WORD文件|*.doc|所有文件|*.*";
                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    string str = saveFileDialog1.FileName;
                    System.Diagnostics.Process.Start(str);
                }
                //Form4 frm4 = new Form4();
                //frm4.Show();
            }
            else
            if (e.Node.Name == "23")
            {
                //tabControl1.Visible = true;
                this.tabControl1.SelectedTab = tabPage8;
            }
            else
            if (e.Node.Name == "31")
            {
                //tabControl1.Visible = true;
                this.tabControl1.SelectedTab = tabPage9;
            }
            else
            if (e.Node.Name == "32")
            {
                //tabControl1.Visible = true;
                this.tabControl1.SelectedTab = tabPage5;
            }
            else
            if (e.Node.Name == "33")
            {
                //tabControl1.Visible = true;
                this.tabControl1.SelectedTab = tabPage21;
            }
            else
            if (e.Node.Name == "41")
            {
                //tabControl1.Visible = true;
                this.panel1.Visible = true;
                this.tabControl1.SelectedTab = tabPage12;
                for (int i = 0; i < 8; i++)
                {
                    DataGridViewRow row = new DataGridViewRow();
                    dataGridView5.Rows.Add(row);
                }
            }
            else 
            if (e.Node.Name == "42")
                {
                    //tabControl1.Visible = true;
                    this.tabControl1.SelectedTab = tabPage10;
                    for (int i = 0; i < 8; i++)
                    {
                        DataGridViewRow row = new DataGridViewRow();
                        dataGridView6.Rows.Add(row);
                    }
                }
            else
                {
                    this.tabControl1.SelectedTab = tabPage2;
                    
                }

            //string name = treeView1.SelectedNode.Text;
            //MessageBox.Show(string.Format("选中了节点{0}", name));
        }

        private void 选择设备ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form2 frm2 = new Form2();
            frm2.Show();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //tabControl1.ItemsSize =new Size(1,1);
            tabControl1.ItemSize = new Size(1, 1);
            this.tabControl1.Location = new Point(this.tabControl1.Location.X, this.tabControl1.Location.Y - 1);
        }

        private void tabPage9_Click(object sender, EventArgs e)
        {

        }

        private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
